home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
pc
/
mac_file
/
vendor_d
/
neuralwa
/
nw2v50
/
lk_map.c
< prev
next >
Wrap
Text File
|
1993-08-23
|
8KB
|
392 lines
/* lk_map.c */
/* 2 input node, 3 output node userio program to
demonstrate Leonard/Kramer fault disgnosis problem */
/* Assumptions:
(a) training data in file are assumed to lie between
-1.0 and 1.0 (Extrapolation is shown between -1.5 and 1.5
(b) No minmax table is used
If used with save-best, set objective function to be UserIO.
*/
/************************************************************************
* Copyright(C) 1987-1993 NeuralWare Inc *
* Penn Center West, IV-227, Pittsburgh, PA 15276 *
* Telephone: (412) 787-8222 FAX: (412) 787-8220 *
* *
* All rights reserved. No part of this program may be reproduced, *
* stored in a retrieval system, or transmitted, in any form or by any *
* means, electronic, mechanical, photocopying, recording or otherwise *
* without the prior written permission of the copyright owner, *
* NeuralWare, Inc. *
* *
* PROPRIETARY NOTICE *
* *
* This document is the property of NeuralWare, Inc. and contains *
* trade-secrets and other proprietary information. The information *
* herein is reserved as proprietary to NeuralWare, and is not to be *
* published, reproduced, copied, disclosed, used, or reverse *
* engineered without the express written consent of a duly authorized *
* representative of NeuralWare. *
************************************************************************
*/
#define UIO_SERVER 1
#define SERVER_EMULATOR_FILE 1
#define SKIP_COMPAT_DATA 1
#include "userutl.h"
#include "uio_strc.h"
#include "uio_tran.h"
#include "uio_reqs.pro"
#include "uio_cmds.pro"
#include <math.h>
#ifdef MAC
#include "macuio.redef"
#endif
#define DO_BLIT 1
#define W_WDTH 200 /* basic defining parameters */
#define W_HGHT 200 /* height of graph */
long file_count = 0l;
#define SBUF_ALC 200
TEXT sbuf[SBUF_ALC];
int back_color;
int on_color;
#define COLOR_MAX 3
int color[COLOR_MAX];
int savebestf; /* Save best flag */
float xin, yin; /* Real coords of recall point */
int x_rcl, y_rcl; /* Graphics coords of recall point */
#define W0 1
#define W1 2
#define PIXEL_WIDTH 3
#ifdef DO_BLIT
#define BLIT_DIMX (((W_WDTH-1)/PIXEL_WIDTH)+1)
#define BLIT_DIMY (((W_HGHT-1)/PIXEL_WIDTH)+1)
TEXT blit[BLIT_DIMY][BLIT_DIMX];
#endif
NINT UIO_Init(file)
TEXT *file;
{
NINT ret_val = UIO_OK;
NINT xsize, ysize, ncolor, chrx, chry; /* graphics parameters */
TEXT *filen;
FILE *fp;
savebestf = 0;
/* Get screen parameters */
ug_gparms( &xsize, &ysize, &ncolor, &chrx, &chry);
if ( ncolor < 8 ) {
PutStr("Require at least 8 colors or gray levels to run this demo\n");
return(UIO_ERROR);
}
color[0] = 4;
color[1] = 6;
color[2] = 1;
on_color = 15;
back_color = 0;
/* Set up windows */
ug_window(W0, back_color, 20, 130, 20+W_WDTH, 130+W_HGHT);
ug_window(W1, 0, 20, 47, 20+W_WDTH, 129);
/* Get file count so we can calculate epochs */
ug_rdfileinf(&filen,0,&file_count);
if (file_count <= 0l)
file_count = 1l;
return(ret_val);
}
NINT UIO_Term(process)
NINT process;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Attention()
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Learn_Start()
{
NINT ret_val = UIO_OK;
/* Set up learn file; use selected file */
ug_fileio("", 0, 1, 1, 1);
return(ret_val);
}
NINT UIO_Learn_Input(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Learn_Output(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Learn_Result(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Learn_End()
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Recall_Start()
{
NINT ret_val = UIO_OK;
TEXT *sp;
x_rcl = PIXEL_WIDTH>>1;
y_rcl = PIXEL_WIDTH>>1;
#ifdef DO_BLIT
PutStr("Testing ...");
#else
ug_winclr(W0);
ug_winclr(W1);
#endif
return(ret_val);
}
NINT UIO_Read(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
/* Assume data lies between -1.5 and 1,5 */
xin = ((3*x_rcl) / (float)W_WDTH) - 1.5;
yin = ((3*y_rcl) / (float)W_HGHT) - 1.5;
Datap[0] = xin;
Datap[1] = yin;
return(ret_val);
}
NINT UIO_Write(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
SREAL outval;
NINT wx;
#ifdef DO_BLIT
NINT blitx, blity;
#endif
if (nPEs > 1) {
NINT maxx;
SREAL maxval;
maxval = -1000.0;
maxx = 0;
/* Find PE with Max value */
for (wx=0; wx < nPEs; wx++) {
if (Datap[wx] > maxval) {
maxx = wx;
maxval = Datap[wx];
}
}
wx = maxx;
}
if (wx >= COLOR_MAX)
wx = COLOR_MAX-1;
else if (wx < 0)
wx = 0;
#ifdef DO_BLIT
blitx = (x_rcl-1)/PIXEL_WIDTH;
blity = (y_rcl-1)/PIXEL_WIDTH;
blit[blity][blitx] = color[wx];
#else
if (color[wx] != back_color)
ug_boxf(W0, color[wx], 0,
x_rcl-1,y_rcl-1,x_rcl+1,y_rcl+1);
#endif
x_rcl += PIXEL_WIDTH;
if (x_rcl > W_WDTH) {
x_rcl = PIXEL_WIDTH>>1;
y_rcl += PIXEL_WIDTH;
#ifdef DO_BLIT
/* Want to know we're still alive */
PutStr(".");
#endif
}
#ifdef DO_BLIT
/* End of recall; now BLIT the image */
if (y_rcl >= W_HGHT) {
ug_winclr(W0);
ug_winclr(W1);
ug_blit(W0, 0, 0, 0, PIXEL_WIDTH, PIXEL_WIDTH,
BLIT_DIMX, BLIT_DIMY, (char *)&blit[0][0] );
/* Following box represents limit of training data, assuming
it lies between -1.0 and 1.0 */
ug_box(W0, 7, 0,
(NINT)((SREAL)W_WDTH/6.0),
(NINT)((SREAL)W_HGHT/6.0),
(NINT)((SREAL)W_WDTH*5.0/6.0),
(NINT)((SREAL)W_HGHT*5.0/6.0),
0);
ug_boxf(W1, color[0], 0, 15, 52, 35, 72);
ug_puts(W1,on_color,0,50,52,"Class 1 (Normal)",0);
ug_boxf(W1, color[1], 0, 15, 28, 35, 48);
ug_puts(W1,on_color,0,50,28,"Class 2 (Fault 1)",0);
ug_boxf(W1, color[2], 0, 15, 4, 35, 24);
ug_puts(W1,on_color,0,50,4,"Class 3 (Fault 2)",0);
PutStr("\n");
}
#endif
if (y_rcl >= W_HGHT)
return( UIO_EXIT);
else
return( UIO_OK);
}
NINT UIO_Write_Step(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Recall_Test(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Recall_End()
{
NINT ret_val = UIO_OK;
if (!savebestf) {
PutStr("Hit <Enter> to continue:");
GetStr( );
}
return(ret_val);
}
NINT UIO_Instrument(Instrument_id, nDataElems, DataElemp)
NINT Instrument_id;
NINT nDataElems;
SREAL *DataElemp;
{
NINT ret_val = UIO_OK;
return(ret_val);
}
/* FUNCTION */
NINT UIO_ObjFunc(eoeflag, DataElemp)
NINT eoeflag;
SREAL *DataElemp;
{
NINT ret_val = UIO_OK;
if (eoeflag)
savebestf = 0; /* Clear save best flag */
else
savebestf = 1; /* Tell recall we are in savebest mode */
return(ret_val);
}
NINT UIO_Rewind()
{
NINT ret_val = UIO_OK;
return(ret_val);
}
NINT UIO_Explain(LayN, nPEs, Datap)
NINT LayN;
NINT nPEs;
SREAL *Datap;
{
NINT ret_val = UIO_OK;
return(ret_val);
}